package org.gap.wizards.items.effects;

import org.gap.wizards.creature.Creature.Attribute;
import org.gap.wizards.effects.Effect;
import org.gap.wizards.utils.Dice;
import org.gap.wizards.utils.Persistence;

public abstract class AttributeEffect implements Effect {
	protected Attribute attribute;
	protected Dice sidedDie;

	public AttributeEffect(Attribute attribute, Dice sidedDie) {
		this.attribute = attribute;
		this.sidedDie = sidedDie;
	}

	@Override
	public void persist(Persistence writer) {
		writer.set("attribute", attribute.name());
		writer.set("dice", sidedDie.name());
	}
	
	@Override
	public void load(Persistence data) {
		attribute = Attribute.valueOf(data.getString("attribute"));
		sidedDie = Dice.valueOf(data.getString("dice"));
	}

	public boolean equals(AttributeEffect obj) {
		return attribute == obj.attribute && sidedDie == obj.sidedDie;
	}
}
